import datetime
from flask import Blueprint, request
from conn_mysql import ConnectMysql
from .access_token_notify import access_token_verify_func

app_get_phone = Blueprint('app_get_phone', 'api')

@app_get_phone.route('/app_get_phone', methods=['POST'])
def get_phone():

    user_id = request.form.get('user_id')
    access_token =request.form.get('access_token')

    verify_result = access_token_verify_func(access_token, user_id)

    if verify_result['status'] != 1:

        return verify_result

    else:

        with ConnectMysql() as c:

            sql = "SELECT * FROM user_table WHERE id=%s"

            result = c.select_one(sql, (user_id,))

        return {
            "status": 1,
            "errorCode": None,
            "errorMsg": None,
            "resultBody": result['user'],
        }

